package com.huanuo.internetofthings.service.deviceType;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.unicorn.framework.base.base.AbstractService;
import org.unicorn.framework.core.SysCode;
import org.unicorn.framework.core.exception.PendingException;

import com.huanuo.internetofthings.bo.deviceType.DeviceType;
import com.huanuo.internetofthings.dao.deviceType.DeviceTypeMapper;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiebin
 * @since 2018-07-19
 */
@Service
public class DeviceTypeService extends AbstractService  {
  @Autowired
  private DeviceTypeMapper deviceTypeMapper;
  /**
     * 根据主键删除记录
     * @param id
     * @return
     * @throws PendingException
     */
  public void deleteByPrimaryKey(Integer id) throws PendingException{
    try {
			 deviceTypeMapper.deleteByPrimaryKey(id);
		} catch (Exception e) {
			error("删除记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "删除记录失败");
	}
    
  }


   /**
     * 保存记录
     * @param record
     * @return
     * @throws PendingException
     */
   public  DeviceType save(DeviceType record) throws PendingException{
       try {
			 deviceTypeMapper.insertSelective(record);
			 return record;
		} catch (Exception e) {
			error("新增记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "新增记录失败");
	}
   }
      /**
     * 根据主键查询记录
     * @param record
     * @return
     * @throws PendingException
     */
    public DeviceType selectByPrimaryKey(Integer id) throws PendingException{
    try {
			return deviceTypeMapper.selectByPrimaryKey(id);
		} catch (Exception e) {
			error("查询记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "查询记录失败");
	}
    }
    
     /**
     * 根据条件查询记录列表
     * @param record
     * @return
     * @throws PendingException
     */
    public  List<DeviceType> selectList(DeviceType record) throws PendingException{
       try {
			return deviceTypeMapper.selectList(record);
		} catch (Exception e) {
			error("查询列表失败", e);
			throw new PendingException(SysCode.DB_ERROR, "查询列表失败");
	}
    }
    /**
     * 根据主键列表查询记录
     * @param record
     * @return
     * @throws PendingException
     */
    public  List<DeviceType> selectListByIds(List<Integer> ids) throws PendingException{
     try {
			return deviceTypeMapper.selectListByIds(ids);
		} catch (Exception e) {
			error("根据ID列表批量查询记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "根据ID列表批量查询记录失败");
	}
    }
   /**
     * 根据条件查询一条记录
     * @param record
     * @return
     * @throws PendingException
     */
    public  DeviceType selectOne(DeviceType record) throws PendingException{
      try {
			return deviceTypeMapper.selectOne(record);
		} catch (Exception e) {
			error("查询单条记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "查询单条记录失败");
	}
    }

    /**
     * 根据主键修改记录
     * @param record
     * @return
     * @throws PendingException
     */
    public DeviceType updateByPrimaryKey(DeviceType record) throws PendingException{
       try {
			 deviceTypeMapper.updateByPrimaryKey(record);
			return record;
		} catch (Exception e) {
			error("根据主键更新单条记录失败", e);
			throw new PendingException(SysCode.DB_ERROR, "根据主键更新单条记录失败");
	}
    }
}
